В Python нет операции инкремента ++ как в си-подобных языках, поэтому используется x += 1. Однако запись ++x является валидным кодом (но не x++), так как это просто два унарных оператора сложения.
При применении унарного плюса у объекта вызывается магический метод __pos__, то есть запись ++x можно понять как x.__pos__().__pos__(). Зная это, можно реализовать класс, который будет представлять число и поддерживать поведение инкремента.
Код на картинке может показаться сначала немного сложным, но лучше проследить логику и понять работу метода __pos__. Если реализовать все остальные необходимо магические методы, то может получится полноценный класс числа, но в продакшне такие приколы лучше не писать.
В Python нет операции инкремента ++ как в си-подобных языках, поэтому используется x += 1. Однако запись ++x является валидным кодом (но не x++), так как это просто два унарных оператора сложения.
При применении унарного плюса у объекта вызывается магический метод __pos__, то есть запись ++x можно понять как x.__pos__().__pos__(). Зная это, можно реализовать класс, который будет представлять число и поддерживать поведение инкремента.
Код на картинке может показаться сначала немного сложным, но лучше проследить логику и понять работу метода __pos__. Если реализовать все остальные необходимо магические методы, то может получится полноценный класс числа, но в продакшне такие приколы лучше не писать.
Traders also expressed uncertainty about the situation with China Evergrande, as the indebted property company has not provided clarification about a key interest payment.In economic news, the Commerce Department reported an unexpected increase in U.S. new home sales in August.Crude oil prices climbed Friday and front-month WTI oil futures contracts saw gains for a fifth straight week amid tighter supplies. West Texas Intermediate Crude oil futures for November rose $0.68 or 0.9 percent at 73.98 a barrel. WTI Crude futures gained 2.8 percent for the week.
Telegram and Signal Havens for Right-Wing Extremists
Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.